package cn.iocoder.yudao.module.wine.controller.app.membertype;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.wine.controller.app.membertype.vo.AppMemberTypePageReqVO;
import cn.iocoder.yudao.module.wine.controller.app.membertype.vo.AppMemberTypeRespVO;
import cn.iocoder.yudao.module.wine.dal.dataobject.membertype.MemberTypeDO;
import cn.iocoder.yudao.module.wine.service.membertype.MemberTypeService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

import java.util.List;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "app  - 会员类型信息")
@RestController
@RequestMapping("/wine/member-type")
@Validated
public class AppMemberTypeController {

    @Resource
    private MemberTypeService memberTypeService;


    @GetMapping("/get")
    @Operation(summary = "获得会员类型信息")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    public CommonResult<AppMemberTypeRespVO> getMemberType(@RequestParam("id") Long id) {
        MemberTypeDO memberType = memberTypeService.getMemberType(id);
        return success(BeanUtils.toBean(memberType, AppMemberTypeRespVO.class));
    }

    @GetMapping("/list")
    @Operation(summary = "获得所有会员类型")
    public CommonResult<List<AppMemberTypeRespVO>> getMemberTypeList(@Valid AppMemberTypePageReqVO pageReqVO) {
        List<MemberTypeDO> list = memberTypeService.getMemberTypeList(pageReqVO);
        return success(BeanUtils.toBean(list, AppMemberTypeRespVO.class));
    }

}
